package com.oscarmovie;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;



import com.oscarmovie.model.Movie;
import com.oscarmovie.model.Mpr;
import com.oscarmovie.model.MovieRelationship;
import com.oscarmovie.service.MovieService;

public class Test {
	
	public static void main(String[] args) {
		testSpring();
	}

	public static void testSpring() {
		Resource resource = new FileSystemResource(new File(
				"E:/eclipse/workspace/OscarMovie/WEB-INF/applicationContext.xml"));
		BeanFactory factory = new XmlBeanFactory(resource);

		// ==Update via SERVICE
		MovieService movieService = (MovieService) factory.getBean("movieServiceX");
		Movie movie = movieService.load(10201);
		Set<Mpr> moviePersons = movie.getMprs();
		for (Mpr moviePerson : moviePersons) {
			System.out.println(moviePerson);
		}
		// List<Movie> movies = movieService.loadAll();
		// for (Movie movie : movies)
		// System.out.println(movie);
	}

	public static void testHibernate() {
		Configuration cfg = new Configuration().configure();
		SessionFactory sessionFactory = cfg.buildSessionFactory();
		Session session = sessionFactory.openSession();
		
		
		System.out.println(MovieRelShipUtil.getMovieIdString(83, 0, 0, 0, 0, 0));
	}
	
}
